package com.java1234.controller;

import java.io.File;
import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

@Controller
public class FileUploadController {
	
	@RequestMapping("/upload")
	public String upload(@RequestParam("file1") MultipartFile file1 , HttpServletRequest request) throws IllegalStateException, IOException{
		String path = request.getServletContext().getRealPath("/");
		System.out.println("path:"+path);
		file1.transferTo(new File(path+"upload/"+file1.getOriginalFilename()));
		return "redirect:success.html";
		
	}

}
